package com.ztstkj.lzservices.utils

import android.app.ActivityManager
import android.content.Context
import com.sscl.baselibrary.utils.DebugUtil

object ServiceAliveUtils {
    fun isServiceAlice(context: Context, serviceName: String): Boolean {
        var isServiceRunning = false
        val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        val services = manager.getRunningServices(Integer.MAX_VALUE)
        for (item in services) {
            if (item.service.className == serviceName) isServiceRunning = true
        }
        DebugUtil.debugOut("isServiceAlice(): $serviceName : $isServiceRunning")
        return isServiceRunning
    }
}